﻿#include "cplaticon.h"

CPlatIcon::CPlatIcon()
{

}

QJsonObject CPlatIcon::toJson() {
    QJsonObject obj;
    obj["icon"] = icon;
    obj["icon_size"] = iconsize;
    obj["pix_width"] = pixsize.width();
    obj["pix_height"] = pixsize.height();
    obj["family"] = static_cast<int>(family);
    obj["color"] = color.name();
    return obj;
}

void CPlatIcon::fromJson(const QJsonObject &obj)
{
    icon = obj["icon"].toInt();
    iconsize = obj["icon_size"].toInt();
    pixsize.setWidth(obj["pix_width"].toInt());
    pixsize.setHeight(obj["pix_height"].toInt());
    family = static_cast<IconHelper::EFonts>(obj["family"].toInt());
    color = QColor(obj["color"].toString());
}

QPixmap CPlatIcon::getPix() {
    IconHelper* iconMgr = IconHelper::instance();
    return iconMgr->getPixmap(color,family ,icon, iconsize, pixsize.width(), pixsize.height());
}
